home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 June: Reference Library / Dev.CD Jun 96 RL / Dev.CD Jun 96 RL.toast / What's New? / Tool Chest / Text / WASTE 1.2a6 / WASTE Pascal Interfaces / WASTE.p < prev   
Encoding:
Text File  |  1996-04-22  |  24.9 KB  |  822 lines  |  [TEXT/CWIE]

  1. unit WASTE;
  2.  
  3. { Pascal interface to the WASTE text engine }
  4.  
  5. { version 1.2a6 (April 1996) }
  6.  
  7. { Copyright © 1993-1996 Marco Piovanelli }
  8. { All Rights Reserved }
  9.  
  10. interface
  11.     uses
  12.         ConditionalMacros,
  13.         Types,
  14.         MixedMode,
  15.         QuickdrawText,
  16.         Quickdraw,
  17.         Script,
  18.         TextUtils,
  19.         TextEdit,
  20.         Drag,
  21.         LongCoords;
  22.  
  23. {$PUSH}
  24. {$ALIGN MAC68K}
  25.  
  26.     const
  27.  
  28. { result codes }
  29.  
  30.         weCantUndoErr = -10015;                    { undo buffer is clear (= errAECantUndo) }
  31.         weEmptySelectionErr = -10013;            { empty selection range (= errAENoUserSelection) }
  32.         weNotHandledErr = -1708;                    { please use default behavior (= errAEEventNotHandled) }
  33.         weUnknownObjectTypeErr = -9478;        { specified object type is not registered }
  34.         weObjectNotFoundErr = -9477;                { no object found at specified offset }
  35.         weReadOnlyErr = -9476;                        { cannot modify instance }
  36.         weUndefinedSelectorErr = -50;                { unknown selector (= paramErr) }
  37.  
  38. { alignment styles }
  39.  
  40.         weFlushLeft = -2;                        { flush left }
  41.         weFlushRight = -1;                    { flush right }
  42.         weFlushDefault = 0;                    { flush according to system direction }
  43.         weCenter = 1;                            { centered }
  44.         weJustify = 2;                            { fully justified }
  45.  
  46. { values for the mode parameter in WESetStyle and WEContinuousStyle }
  47.  
  48.         weDoFont                         = $0001;    { set font family number }
  49.         weDoFace                         = $0002;    { set Quickdraw styles }
  50.         weDoSize                             = $0004;    { set type size }
  51.         weDoColor                         = $0008;    { set color }
  52.         weDoAll                             = weDoFont + weDoFace + weDoSize + weDoColor;
  53.         weDoAddSize                     = $0010;    { adjust type size }
  54.         weDoToggleFace                 = $0020;    { turn a style off if it's continuous over the selection }
  55.         weDoReplaceFace                 = $0040;    { replace existing styles outright }
  56.         weDoPreserveScript            = $0080;    { don't change scripts when applying a font change }
  57.         weDoExtractSubscript         = $0100;    { extract subscripts when applying a font change }
  58.         weDoFaceMask                 = $0200;    { set Quickdraw styles using mask field }
  59.  
  60. { values for the edge parameter in WEGetOffset etc. }
  61.  
  62.         kLeadingEdge = -1;                    { point is on the leading edge of a glyph }
  63.         kTrailingEdge = 0;                        { point is on the trailing edge of a glyph }
  64.         kObjectEdge = 2;                        { point is in the middle of an embedded object }
  65.  
  66. { values for WEFeatureFlag feature parameter }
  67.  
  68.         weFAutoScroll                 = 0;            { automatically scroll the selection range into view }
  69.         weFOutlineHilite             = 2;            { frame selection when deactivated }
  70.         weFReadOnly                 = 5;            { disallow modifications }
  71.         weFUndo                         = 6;            { support WEUndo }
  72.         weFIntCutAndPaste         = 7;            { use intelligent cut-and-paste rules }
  73.         weFDragAndDrop         = 8;            { support drag-and-drop text editing }
  74.         weFInhibitRecal             = 9;            { don't recalculate line starts and don't redraw text }
  75.         weFUseTempMem         = 10;            { use temporary memory for main data structures }
  76.         weFDrawOffscreen         = 11;            { draw text offscreen for smoother visual results }
  77.         weFInhibitRedraw         = 12;            { don't redraw text }
  78.         weFMonoStyled            = 13;            { disallow style changes }
  79.         weFInhibitColor             = 31;            { draw in black & white only }
  80.  
  81. { values for WENew flags parameter }
  82.  
  83.         weDoAutoScroll                 = $00000001;
  84.         weDoOutlineHilite             = $00000004;
  85.         weDoReadOnly                     = $00000020;
  86.         weDoUndo                         = $00000040;
  87.         weDoIntCutAndPaste         = $00000080;
  88.         weDoDragAndDrop             = $00000100;
  89.         weDoInhibitRecal             = $00000200;
  90.         weDoUseTempMem             = $00000400;
  91.         weDoDrawOffscreen             = $00000800;
  92.         weDoInhibitRedraw            = $00001000;
  93.         weDoMonoStyled                = $00002000;
  94.         weDoInhibitColor                = $80000000;
  95.  
  96. { values for WEFeatureFlag action parameter }
  97.  
  98.         weBitToggle = -2;                        { toggles the specified feature }
  99.         weBitTest = -1;                            { returns the current setting of the specified feature }
  100.         weBitClear = 0;                            { disables the specified feature }
  101.         weBitSet = 1;                            { enables the specified feature }
  102.  
  103. { values for WEGetInfo and WESetInfo selector parameter }
  104.  
  105.         weCharByteHook = 'cbyt';                { CharByte hook }
  106.         weCharToPixelHook = 'c2p ';            { CharToPixel hook }
  107.         weCharTypeHook = 'ctyp';                { CharType hook }
  108.         weClickLoop = 'clik';                        { click loop callback }
  109.         weCurrentDrag = 'drag';                { drag currently being tracked from WEClick }
  110.         weDrawTextHook = 'draw';            { text drawing hook }
  111.         weHiliteDropAreaHook = 'hidr';        { drop area highlighting hook }
  112.         weLineBreakHook = 'lbrk';            { line breaking hook }
  113.         wePixelToCharHook = 'p2c ';            { PixelToChar hook }
  114.         wePort = 'port';                                { graphics port }
  115.         weRefCon = 'refc';                            { reference constant for use by application }
  116.         weScrollProc = 'scrl';                        { scroll callback }
  117.         weText = 'text';                                { handle to the raw text }
  118.         weTranslateDragHook = 'xdrg';        { drag translation callback }
  119.         weTSMDocumentID = 'tsmd';            { Text Services Manager document ID }
  120.         weTSMPreUpdate = 'pre ';                { Text Services Manager pre-update callback }
  121.         weTSMPostUpdate = 'post';            { Text Services Manager post-update callback }
  122.         weURLHint = 'urlh';                        { URL hint string for Internet Config }
  123.         weWordBreakHook = 'wbrk';        { word breaking hook }
  124.  
  125. { values for WEInstallObjectHandler handlerSelector parameter }
  126.  
  127.         weNewHandler = 'new ';            { new handler }
  128.         weDisposeHandler = 'free';        { dispose handler }
  129.         weDrawHandler = 'draw';            { draw handler }
  130.         weClickHandler = 'clik';                { click handler }
  131.         weStreamHandler = 'strm';        { stream handler }
  132.  
  133. { action kinds }
  134.  
  135.         weAKNone                 = 0;                { null action }
  136.         weAKUnspecified     = 1;                { action of unspecified nature }
  137.         weAKTyping             = 2;                { some text has been typed in }
  138.         weAKCut                     = 3;                { the selection range has been cut }
  139.         weAKPaste                 = 4;                { something has been pasted }
  140.         weAKClear                 = 5;                { the selection range has been deleted }
  141.         weAKDrag                 = 6;                { drag and drop operation }
  142.         weAKSetStyle             = 7;                { some style has been applied to a text range }
  143.  
  144. { destination kinds for stream handler }
  145.  
  146.         weToScrap        =    0;
  147.         weToDrag            =    1;
  148.         weToSoup            =    2;
  149.  
  150.     type
  151.  
  152. { if we're using a pre-2.1 version of the Universal Headers, define EventModifiers }
  153. {$IFC UNDEFINED UNIVERSAL_INTERFACES_VERSION}
  154.     type
  155.         EventModifiers = Integer;
  156. {$ENDC}
  157.  
  158. { WASTE data types }
  159.  
  160.         WEReference = Ptr;
  161.         WEObjectReference = Ptr;
  162.         WESoupHandle = Handle;
  163.         WEActionKind = Integer;
  164.         WEAlignment = SignedByte;
  165.         WEStyleMode = Integer;
  166.         WESelector = FourCharCode;
  167.         WEHandle = WEReference;        { obsolete; kept for backward compatibility }
  168.  
  169.         WERunInfo = record
  170.                 runStart: LongInt;                            { byte offset to first character of style run }
  171.                 runEnd: LongInt;                            { byte offset past last character of style run }
  172.                 runHeight: Integer;                        { line height (ascent + descent + leading) }
  173.                 runAscent: Integer;                        { font ascent }
  174.                 runStyle: TextStyle;                        { text attributes }
  175.                 runObject: WEObjectReference;        { either NIL or reference to embedded object }
  176.             end;  { WERunInfo }
  177.  
  178. { callback prototypes }
  179.  
  180. { FUNCTION MyClickLoop(we: WEReference): Boolean; }
  181.         WEClickLoopProcPtr = ProcPtr;
  182.         WEClickLoopUPP = UniversalProcPtr;
  183.  
  184. { PROCEDURE MyScrollProc(we: WEReference); }
  185.         WEScrollProcPtr = ProcPtr;
  186.         WEScrollUPP = UniversalProcPtr;
  187.  
  188. { PROCEDURE MyTSMPreUpdate(we: WEReference); }
  189.         WETSMPreUpdateProcPtr = ProcPtr;
  190.         WETSMPreUpdateUPP = UniversalProcPtr;
  191.  
  192. { PROCEDURE MyTSMPostUpdate(we: WEReference; fixLength: LongInt; }
  193. {         inputAreaStart, inputAreaEnd:LongInt; }
  194. {        pinRangeStart, pinRangeEnd: LongInt); }
  195.         WETSMPostUpdateProcPtr = ProcPtr;
  196.         WETSMPostUpdateUPP = UniversalProcPtr;
  197.  
  198. { FUNCTION MyTranslateDrag (theDrag: DragReference; theItem: ItemReference; }
  199. {         requestedType: FlavorType; putDataHere: Handle): OSErr; }
  200.         WETranslateDragProcPtr = ProcPtr;
  201.         WETranslateDragUPP = UniversalProcPtr;
  202.  
  203. { FUNCTION MyHiliteDropArea (theDrag: DragReference; hiliteFlag: Boolean; }
  204. {        we: WEReference); }
  205.         WEHiliteDropAreaProcPtr = ProcPtr;
  206.         WEHiliteDropAreaUPP = UniversalProcPtr;
  207.  
  208. { PROCEDURE MyDrawText (pText: Ptr; textLength: LongInt; slop: Fixed; }
  209. {         styleRunPosition: JustStyleCode; we: WEReference); }
  210.         WEDrawTextProcPtr = ProcPtr;
  211.         WEDrawTextUPP = UniversalProcPtr;
  212.  
  213. { FUNCTION MyPixelToChar (pText: Ptr; textLength: LongInt; slop: Fixed; }
  214. {         var pixelWidth: Fixed; var edge: SignedByte; }
  215. {         styleRunPosition: JustStyleCode; hPos: Fixed; we: WEReference): LongInt; }
  216.         WEPixelToCharProcPtr = ProcPtr;
  217.         WEPixelToCharUPP = UniversalProcPtr;
  218.  
  219. { FUNCTION MyCharToPixel (pText: Ptr; textLength: LongInt; slop: Fixed; }
  220. {        offset: LongInt; direction: Integer; }
  221. {        styleRunPosition: JustStyleCode; hPos: LongInt; we:WEReference): Integer; }
  222.         WECharToPixelProcPtr = ProcPtr;
  223.         WECharToPixelUPP = UniversalProcPtr;
  224.  
  225. { FUNCTION MyLineBreak (pText: Ptr; textLength: LongInt; }
  226. {        textStart, textEnd: LongInt; var textWidth: Fixed; var textOffset: LongInt; }
  227. {        we: WEReference): StyledLineBreakCode; }
  228.         WELineBreakProcPtr = ProcPtr;
  229.         WELineBreakUPP = UniversalProcPtr;
  230.  
  231. { PROCEDURE MyWordBreak (pText: Ptr; textLength, offset: Integer; edge: SignedByte; }
  232. {                    var breakOffsets: OffsetTable; script: ScriptCode; we: WEReference); }
  233.         WEWordBreakProcPtr = ProcPtr;
  234.         WEWordBreakUPP = UniversalProcPtr;
  235.  
  236. { FUNCTION MyCharByte (pText: Ptr; textOffset: Integer; }
  237. {                     script: ScriptCode; we: WEReference): Integer; }
  238.         WECharByteProcPtr = ProcPtr;
  239.         WECharByteUPP = UniversalProcPtr;
  240.  
  241. { FUNCTION MyCharType (pText: Ptr; textOffset: Integer; }
  242. {                     script: ScriptCode; we: WEReference): Integer; }
  243.         WECharTypeProcPtr = ProcPtr;
  244.         WECharTypeUPP = UniversalProcPtr;
  245.  
  246. { FUNCTION MyNewObject (var defaultObjectSize: Point; }
  247. {                    objectRef: WEObjectReference): OSErr; }
  248.         WENewObjectProcPtr = ProcPtr;
  249.         WENewObjectUPP = UniversalProcPtr;
  250.  
  251. { FUNCTION MyDisposeObject (objectRef: WEObjectReference): OSErr; }
  252.         WEDisposeObjectProcPtr = ProcPtr;
  253.         WEDisposeObjectUPP = UniversalProcPtr;
  254.  
  255. { FUNCTION MyDrawObject (var destRect: Rect; }
  256. {         objectRef: WEObjectReference): OSErr }
  257.         WEDrawObjectProcPtr = ProcPtr;
  258.         WEDrawObjectUPP = UniversalProcPtr;
  259.  
  260. { FUNCTION MyClickObject (hitPt: Point; modifiers: EventModifiers; clickTime: LongInt; }
  261. {         objectRef: WEObjectReference): Boolean; }
  262.         WEClickObjectProcPtr = ProcPtr;
  263.         WEClickObjectUPP = UniversalProcPtr;
  264.  
  265. { FUNCTION MyStreamObject (destKind: Integer; var theType: FlavorType; }
  266. {        putDataHere: Handle; objectRef: WEObjectReference): OSErr; }
  267.         WEStreamObjectProcPtr = ProcPtr;
  268.         WEStreamObjectUPP = UniversalProcPtr;
  269.  
  270.     const
  271.  
  272. { UPP proc info }
  273.  
  274.         uppWEClickLoopProcInfo = $000000D0;
  275.         uppWEScrollProcInfo = $000000C0;
  276.         uppWETSMPreUpdateProcInfo = $000000C0;
  277.         uppWETSMPostUpdateProcInfo = $0003FFC0;
  278.         uppWETranslateDragProcInfo = $00003FE0;
  279.         uppWEHiliteDropAreaProcInfo = $00000DE0;
  280.         uppWEDrawTextProcInfo = $0000EFC0;
  281.         uppWEPixelToCharProcInfo = $003EFFF0;
  282.         uppWECharToPixelProcInfo = $003EBFE0;
  283.         uppWELineBreakProcInfo = $000FFFD0;
  284.         uppWEWordBreakProcInfo = $000EDAC0;
  285.         uppWECharByteProcInfo = $00003AE0;
  286.         uppWECharTypeProcInfo = $00003AE0;
  287.         uppWENewObjectProcInfo = $000003E0;
  288.         uppWEDisposeObjectProcInfo = $000000E0;
  289.         uppWEDrawObjectProcInfo = $000003E0;
  290.         uppWEClickObjectProcInfo = $00003ED0;
  291.         uppWEStreamObjectProcInfo = $00003FA0;
  292.  
  293. { NewProc macros }
  294.  
  295.     function NewWEClickLoopProc (userRoutine: WEClickLoopProcPtr): WEClickLoopUPP;
  296. {$IFC NOT GENERATINGCFM}
  297.     inline
  298.         $2E9F;
  299. {$ENDC}
  300.  
  301.     function NewWEScrollProc (userRoutine: WEScrollProcPtr): WEScrollUPP;
  302. {$IFC NOT GENERATINGCFM}
  303.     inline
  304.         $2E9F;
  305. {$ENDC}
  306.  
  307.     function NewWETSMPreUpdateProc (userRoutine: WETSMPreUpdateProcPtr): WETSMPreUpdateUPP;
  308. {$IFC NOT GENERATINGCFM}
  309.     inline
  310.         $2E9F;
  311. {$ENDC}
  312.  
  313.     function NewWETSMPostUpdateProc (userRoutine: WETSMPostUpdateProcPtr): WETSMPostUpdateUPP;
  314. {$IFC NOT GENERATINGCFM}
  315.     inline
  316.         $2E9F;
  317. {$ENDC}
  318.  
  319.     function NewWETranslateDragProc (userRoutine: WETranslateDragProcPtr): WETranslateDragUPP;
  320. {$IFC NOT GENERATINGCFM}
  321.     inline
  322.         $2E9F;
  323. {$ENDC}
  324.  
  325.     function NewWEHiliteDropAreaProc (userRoutine: WEHiliteDropAreaProcPtr): WEHiliteDropAreaUPP;
  326. {$IFC NOT GENERATINGCFM}
  327.     inline
  328.         $2E9F;
  329. {$ENDC}
  330.  
  331.     function NewWEDrawTextProc (userRoutine: WEDrawTextProcPtr): WEDrawTextUPP;
  332. {$IFC NOT GENERATINGCFM}
  333.     inline
  334.         $2E9F;
  335. {$ENDC}
  336.  
  337.     function NewWEPixelToCharProc (userRoutine: WEPixelToCharProcPtr): WEPixelToCharUPP;
  338. {$IFC NOT GENERATINGCFM}
  339.     inline
  340.         $2E9F;
  341. {$ENDC}
  342.  
  343.     function NewWECharToPixelProc (userRoutine: WECharToPixelProcPtr): WECharToPixelUPP;
  344. {$IFC NOT GENERATINGCFM}
  345.     inline
  346.         $2E9F;
  347. {$ENDC}
  348.  
  349.     function NewWELineBreakProc (userRoutine: WELineBreakProcPtr): WELineBreakUPP;
  350. {$IFC NOT GENERATINGCFM}
  351.     inline
  352.         $2E9F;
  353. {$ENDC}
  354.  
  355.     function NewWEWordBreakProc (userRoutine: WEWordBreakProcPtr): WEWordBreakUPP;
  356. {$IFC NOT GENERATINGCFM}
  357.     inline
  358.         $2E9F;
  359. {$ENDC}
  360.  
  361.     function NewWECharByteProc (userRoutine: WECharByteProcPtr): WECharByteUPP;
  362. {$IFC NOT GENERATINGCFM}
  363.     inline
  364.         $2E9F;
  365. {$ENDC}
  366.  
  367.     function NewWECharTypeProc (userRoutine: WECharTypeProcPtr): WECharTypeUPP;
  368. {$IFC NOT GENERATINGCFM}
  369.     inline
  370.         $2E9F;
  371. {$ENDC}
  372.  
  373.     function NewWENewObjectProc (userRoutine: WENewObjectProcPtr): WENewObjectUPP;
  374. {$IFC NOT GENERATINGCFM}
  375.     inline
  376.         $2E9F;
  377. {$ENDC}
  378.  
  379.     function NewWEDisposeObjectProc (userRoutine: WEDisposeObjectProcPtr): WEDisposeObjectUPP;
  380. {$IFC NOT GENERATINGCFM}
  381.     inline
  382.         $2E9F;
  383. {$ENDC}
  384.  
  385.     function NewWEDrawObjectProc (userRoutine: WEDrawObjectProcPtr): WEDrawObjectUPP;
  386. {$IFC NOT GENERATINGCFM}
  387.     inline
  388.         $2E9F;
  389. {$ENDC}
  390.  
  391.     function NewWEClickObjectProc (userRoutine: WEClickObjectProcPtr): WEClickObjectUPP;
  392. {$IFC NOT GENERATINGCFM}
  393.     inline
  394.         $2E9F;
  395. {$ENDC}
  396.  
  397.     function NewWEStreamObjectProc (userRoutine: WEStreamObjectProcPtr): WEStreamObjectUPP;
  398. {$IFC NOT GENERATINGCFM}
  399.     inline
  400.         $2E9F;
  401. {$ENDC}
  402.  
  403. { CallProc macros }
  404.  
  405.     function CallWEClickLoopProc (we: WEReference;
  406.                                     userRoutine: WEClickLoopUPP): Boolean;
  407. {$IFC NOT GENERATINGCFM}
  408.     inline
  409.         $205F, $4E90;
  410. {$ENDC}
  411.  
  412.     procedure CallWEScrollProc (we: WEReference;
  413.                                     userRoutine: WEScrollUPP);
  414. {$IFC NOT GENERATINGCFM}
  415.     inline
  416.         $205F, $4E90;
  417. {$ENDC}
  418.  
  419.     procedure CallWETSMPreUpdateProc (we: WEReference;
  420.                                     userRoutine: WETSMPreUpdateUPP);
  421. {$IFC NOT GENERATINGCFM}
  422.     inline
  423.         $205F, $4E90;
  424. {$ENDC}
  425.  
  426.     procedure CallWETSMPostUpdateProc (we: WEReference;
  427.                                     fixLength: LongInt;
  428.                                     inputAreaStart, inputAreaEnd: LongInt;
  429.                                     pinRangeStart, pinRangeEnd: LongInt;
  430.                                     userRoutine: WETSMPostUpdateUPP);
  431. {$IFC NOT GENERATINGCFM}
  432.     inline
  433.         $205F, $4E90;
  434. {$ENDC}
  435.  
  436.     function CallWETranslateDragProc (theDrag: DragReference;
  437.                                     theItem: ItemReference;
  438.                                     requestedType: FlavorType;
  439.                                     putDataHere: Handle;
  440.                                     userRoutine: WETranslateDragUPP): OSErr;
  441. {$IFC NOT GENERATINGCFM}
  442.     inline
  443.         $205F, $4E90;
  444. {$ENDC}
  445.  
  446.     function CallWEHiliteDropAreaProc (theDrag: DragReference;
  447.                                     hiliteFlag: Boolean;
  448.                                     we: WEReference;
  449.                                     userRoutine: WEHiliteDropAreaUPP): OSErr;
  450. {$IFC NOT GENERATINGCFM}
  451.     inline
  452.         $205F, $4E90;
  453. {$ENDC}
  454.  
  455.     procedure CallWEDrawTextProc (pText: Ptr;
  456.                                     textLength: LongInt;
  457.                                     slop: Fixed;
  458.                                     styleRunPosition: JustStyleCode;
  459.                                     we: WEReference;
  460.                                     userRoutine: WEDrawTextUPP);
  461. {$IFC NOT GENERATINGCFM}
  462.     inline
  463.         $205F, $4E90;
  464. {$ENDC}
  465.  
  466.     function CallWEPixelToCharProc (pText: Ptr;
  467.                                     textLength: LongInt;
  468.                                     slop: Fixed;
  469.                                     var width: Fixed;
  470.                                     var edge: SignedByte;
  471.                                     styleRunPosition: JustStyleCode;
  472.                                     hPos: Fixed;
  473.                                     we: WEReference;
  474.                                     userRoutine: WEPixelToCharUPP): LongInt;
  475. {$IFC NOT GENERATINGCFM}
  476.     inline
  477.         $205F, $4E90;
  478. {$ENDC}
  479.  
  480.     function CallWECharToPixelProc (pText: Ptr;
  481.                                     textLength: LongInt;
  482.                                     slop: Fixed;
  483.                                     offset: LongInt;
  484.                                     direction: Integer;
  485.                                     styleRunPosition: JustStyleCode;
  486.                                     hPos: LongInt;
  487.                                     we: WEReference;
  488.                                     userRoutine: WECharToPixelUPP): Integer;
  489. {$IFC NOT GENERATINGCFM}
  490.     inline
  491.         $205F, $4E90;
  492. {$ENDC}
  493.  
  494.     function CallWELineBreakProc (pText: Ptr;
  495.                                     textLength: LongInt;
  496.                                     textStart, textEnd: LongInt;
  497.                                     var textWidth: Fixed;
  498.                                     var textOffset: LongInt;
  499.                                     we: WEReference;
  500.                                     userRoutine: WELineBreakUPP): StyledLineBreakCode;
  501. {$IFC NOT GENERATINGCFM}
  502.     inline
  503.         $205F, $4E90;
  504. {$ENDC}
  505.  
  506.     procedure CallWEWordBreakProc (pText: Ptr;
  507.                                     textLength, offset: Integer;
  508.                                     edge: SignedByte;
  509.                                     var breakOffsets: OffsetTable;
  510.                                     script: ScriptCode;
  511.                                     we: WEReference;
  512.                                     userRoutine: WEWordBreakUPP);
  513. {$IFC NOT GENERATINGCFM}
  514.     inline
  515.         $205F, $4E90;
  516. {$ENDC}
  517.  
  518.     function CallWECharByteProc (pText: Ptr;
  519.                                     textOffset: Integer;
  520.                                     script: ScriptCode;
  521.                                     we: WEReference;
  522.                                     userRoutine: WECharByteUPP): Integer;
  523. {$IFC NOT GENERATINGCFM}
  524.     inline
  525.         $205F, $4E90;
  526. {$ENDC}
  527.  
  528.     function CallWECharTypeProc (pText: Ptr;
  529.                                     textOffset: Integer;
  530.                                     script: ScriptCode;
  531.                                     we: WEReference;
  532.                                     userRoutine: WECharTypeUPP): Integer;
  533. {$IFC NOT GENERATINGCFM}
  534.     inline
  535.         $205F, $4E90;
  536. {$ENDC}
  537.  
  538.     function CallWENewObjectProc (var defaultObjectSize: Point;
  539.                                     objectRef: WEObjectReference;
  540.                                     userRoutine: WENewObjectUPP): OSErr;
  541. {$IFC NOT GENERATINGCFM}
  542.     inline
  543.         $205F, $4E90;
  544. {$ENDC}
  545.  
  546.     function CallWEDisposeObjectProc (objectRef: WEObjectReference;
  547.                                     userRoutine: WEDisposeObjectUPP): OSErr;
  548. {$IFC NOT GENERATINGCFM}
  549.     inline
  550.         $205F, $4E90;
  551. {$ENDC}
  552.  
  553.     function CallWEDrawObjectProc ({const} var destRect: Rect;
  554.                                     objectRef: WEObjectReference;
  555.                                     userRoutine: WEDrawObjectUPP): OSErr;
  556. {$IFC NOT GENERATINGCFM}
  557.     inline
  558.         $205F, $4E90;
  559. {$ENDC}
  560.  
  561.     function CallWEClickObjectProc (hitPoint: Point;
  562.                                     modifiers: EventModifiers;
  563.                                     clickTime: LongInt;
  564.                                     objectRef: WEObjectReference;
  565.                                     userRoutine: WEClickObjectUPP): Boolean;
  566. {$IFC NOT GENERATINGCFM}
  567.     inline
  568.         $205F, $4E90;
  569. {$ENDC}
  570.  
  571.     function CallWEStreamObjectProc (destKind: Integer;
  572.                                     var theType: FlavorType;
  573.                                     putDataHere: Handle;
  574.                                     objectRef: WEObjectReference;
  575.                                     userRoutine: WEStreamObjectUPP): OSErr;
  576. {$IFC NOT GENERATINGCFM}
  577.     inline
  578.         $205F, $4E90;
  579. {$ENDC}
  580.  
  581.  
  582. { WASTE PUBLIC CALLS }
  583.  
  584. { creation and destruction }
  585.  
  586.     function WENew ({const} var destRect, viewRect: LongRect;
  587.                                     flags: LongInt;
  588.                                     var we: WEReference): OSErr;
  589.     procedure WEDispose (we: WEReference);
  590.  
  591. { getting variables }
  592.  
  593.     function WEGetText (we: WEReference): Handle;
  594.     function WEGetChar (offset: LongInt;
  595.                                     we: WEReference): Char;
  596.     function WEGetTextLength (we: WEReference): LongInt;
  597.     function WECountLines (we: WEReference): LongInt;
  598.     function WEGetHeight (startLine, endLine: LongInt;
  599.                                     we: WEReference): LongInt;
  600.     procedure WEGetSelection (var selStart, selEnd: LongInt;
  601.                                     we: WEReference);
  602.     procedure WEGetDestRect (var destRect: LongRect;
  603.                                     we: WEReference);
  604.     procedure WEGetViewRect (var viewRect: LongRect;
  605.                                     we: WEReference);
  606.     function WEIsActive (we: WEReference): Boolean;
  607.     function WEOffsetToLine (offset: LongInt;
  608.                                     we: WEReference): LongInt;
  609.     procedure WEGetLineRange (lineNo: LongInt;
  610.                                     var lineStart, lineEnd: LongInt;
  611.                                     we: WEReference);
  612.  
  613. { setting variables }
  614.  
  615.     procedure WESetSelection (selStart, selEnd: LongInt;
  616.                                     we: WEReference);
  617.     procedure WESetDestRect ({const} var destRect: LongRect;
  618.                                     we: WEReference);
  619.     procedure WESetViewRect ({const} var viewRect: LongRect;
  620.                                     we: WEReference);
  621.  
  622. { accessing style run information }
  623.  
  624.     function WEContinuousStyle (var mode: WEStyleMode;
  625.                                     var ts: TextStyle;
  626.                                     we: WEReference): Boolean;
  627.     procedure WEGetRunInfo (offset: LongInt;
  628.                                     var info: WERunInfo;
  629.                                     we: WEReference);
  630.  
  631. { converting byte offsets to screen positions and vice versa }
  632.     function WEGetOffset ({const} var thePoint: LongPt;
  633.                                     var edge: SignedByte;
  634.                                     we: WEReference): LongInt;
  635.     procedure WEGetPoint (offset: LongInt;
  636.                                     var thePoint: LongPt;
  637.                                     var lineHeight: Integer;
  638.                                     we: WEReference);
  639.  
  640. { finding words and lines }
  641.     procedure WEFindWord (offset: LongInt;
  642.                                     edge: SignedByte;
  643.                                     var wordStart, wordEnd: LongInt;
  644.                                     we: WEReference);
  645.     procedure WEFindLine (offset: LongInt;
  646.                                     edge: SignedByte;
  647.                                     var lineStart, lineEnd: LongInt;
  648.                                     we: WEReference);
  649.  
  650. { making a copy of a text range }
  651.  
  652.     function WECopyRange (rangeStart, rangeEnd: LongInt;
  653.                                     hText: Handle;
  654.                                     hStyles: StScrpHandle;
  655.                                     hSoup: WESoupHandle;
  656.                                     we: WEReference): OSErr;
  657.  
  658. { getting and setting the alignment style }
  659.  
  660.     function WEGetAlignment (we: WEReference): WEAlignment;
  661.     procedure WESetAlignment (alignment: WEAlignment;
  662.                                     we: WEReference);
  663.  
  664. { recalculating line breaks, drawing and scrolling }
  665.  
  666.     function WECalText (we: WEReference): OSErr;
  667.     procedure WEUpdate (updateRgn: RgnHandle;
  668.                                     we: WEReference);
  669.     procedure WEScroll (hOffset, vOffset: LongInt;
  670.                                     we: WEReference);
  671.     procedure WESelView (we: WEReference);
  672.  
  673. { handling activate/deactivate events }
  674.  
  675.     procedure WEActivate (we: WEReference);
  676.     procedure WEDeactivate (we: WEReference);
  677.  
  678. { handling key-down events }
  679.  
  680.     procedure WEKey (key: Char;
  681.                                     modifiers: EventModifiers;
  682.                                     we: WEReference);
  683.  
  684. { handling mouse-down events and mouse tracking }
  685.  
  686.     procedure WEClick (hitPt: Point;
  687.                                     modifiers: EventModifiers;
  688.                                     clickTime: LongInt;
  689.                                     we: WEReference);
  690.  
  691. { adjusting the cursor shape }
  692.  
  693.     function WEAdjustCursor (mouseLoc: Point;
  694.                                     mouseRgn: RgnHandle;
  695.                                     we: WEReference): Boolean;
  696.  
  697. { blinking the caret }
  698.  
  699.     procedure WEIdle (var maxSleep: LongInt;
  700.                                     we: WEReference);
  701.  
  702. { modifying the text and the styles }
  703.  
  704.     function WEInsert (pText: Ptr;
  705.                                     textLength: LongInt;
  706.                                     hStyles: StScrpHandle;
  707.                                     hSoup: WESoupHandle;
  708.                                     we: WEReference): OSErr;
  709.     function WEDelete (we: WEReference): OSErr;
  710.     function WESetStyle (mode: WEStyleMode;
  711.                                     {const} var ts: TextStyle;
  712.                                     we: WEReference): OSErr;
  713.     function WEUseText (hText: Handle;
  714.                                     we: WEReference): OSErr;
  715.     function WEUseStyleScrap (hStyles: StScrpHandle;
  716.                                     we: WEReference): OSErr;
  717.  
  718. { undo }
  719.  
  720.     function WEUndo (we: WEReference): OSErr;
  721.     procedure WEClearUndo (we: WEReference);
  722.     function WEGetUndoInfo (var redoFlag: Boolean;
  723.                                     we: WEReference): WEActionKind;
  724.     function WEIsTyping (we: WEReference): Boolean;
  725.  
  726. { keeping track of changes }
  727.  
  728.     function WEGetModCount (we: WEReference): LongInt;
  729.     procedure WEResetModCount (we: WEReference);
  730.  
  731. { embedded objects }
  732.  
  733.     function WEInstallObjectHandler (objectType: FlavorType;
  734.                                     handlerSelector: WESelector;
  735.                                     handler: ProcPtr;
  736.                                     we: WEReference): OSErr;
  737.     function WEGetObjectHandler (objectType: FlavorType;
  738.                                     handlerSelector: WESelector;
  739.                                     var handler: ProcPtr;
  740.                                     we: WEReference): OSErr;
  741.     function WEInsertObject (objectType: FlavorType;
  742.                                     objectDataHandle: Handle;
  743.                                     objectSize: Point;        { (0, 0) means default size }
  744.                                     we: WEReference): OSErr;
  745.     function WEGetSelectedObject (var objectRef: WEObjectReference;
  746.                                     we: WEReference): OSErr;
  747.     function WEFindNextObject (offset: LongInt;
  748.                                     var objectRef: WEObjectReference;
  749.                                     we: WEReference): LongInt;
  750.     function WEUseSoup (hSoup: WESoupHandle;
  751.                                     we: WEReference): LongInt;
  752.  
  753. { accessing embedded object attributes }
  754.     function WEGetObjectType (objectRef: WEObjectReference): FlavorType;
  755.     function WEGetObjectDataHandle (objectRef: WEObjectReference): Handle;
  756.     function WEGetObjectSize (objectRef: WEObjectReference): Point;
  757.     function WEGetObjectOwner (objectRef: WEObjectReference): WEReference;
  758.     function WEGetObjectRefCon (objectRef: WEObjectReference): LongInt;
  759.     procedure WESetObjectRefCon (objectRef: WEObjectReference;
  760.                                     refCon: LongInt);
  761.  
  762. { Clipboard operations }
  763.     function WECut (we: WEReference): OSErr;
  764.     function WECopy (we: WEReference): OSErr;
  765.     function WEPaste (we: WEReference): OSErr;
  766.     function WECanPaste (we: WEReference): Boolean;
  767.  
  768. { Drag Manager support }
  769.     function WEGetHiliteRgn (rangeStart, rangeEnd: LongInt;
  770.                                     we: WEReference): RgnHandle;
  771.     function WETrackDrag (message: DragTrackingMessage;
  772.                                     drag: DragReference;
  773.                                     we: WEReference): OSErr;
  774.     function WEReceiveDrag (drag: DragReference;
  775.                                     we: WEReference): OSErr;
  776.     function WECanAcceptDrag (drag: DragReference;
  777.                                     we: WEReference): Boolean;
  778.     function WEDraggedToTrash (drag: DragReference): Boolean;
  779.  
  780. { Script Manager utilities }
  781.     function WECharByte (offset: LongInt;
  782.                                     we: WEReference): Integer;
  783.     function WECharType (offset: LongInt;
  784.                                     we: WEReference): Integer;
  785.  
  786. { Text Services Manager support }
  787.     function WEInstallTSMHandlers: OSErr;
  788.     function WERemoveTSMHandlers: OSErr;
  789.     procedure WEStopInlineSession (we: WEReference);
  790.  
  791. { additional features }
  792.     function WEFeatureFlag (feature: Integer;
  793.                                     action: Integer;
  794.                                     we: WEReference): Integer;
  795.     function WEGetInfo (selector: WESelector;
  796.                                     info: univ Ptr;
  797.                                     we: WEReference): OSErr;
  798.     function WESetInfo (selector: WESelector;
  799.                                     info: univ Ptr;
  800.                                     we: WEReference): OSErr;
  801.  
  802. { long coordinates utility routines }
  803.     procedure WELongPointToPoint ({const} var lp: LongPt;
  804.                                     var p: Point);
  805.     procedure WEPointToLongPoint (p: Point;
  806.                                     var lp: LongPt);
  807.     procedure WESetLongRect (var lr: LongRect;
  808.                                     left, top, right, bottom: LongInt);
  809.     procedure WELongRectToRect ({const} var lr: LongRect;
  810.                                     var r: Rect);
  811.     procedure WERectToLongRect ({const} var r: Rect;
  812.                                     var lr: LongRect);
  813.     procedure WEOffsetLongRect (var lr: LongRect;
  814.                                     hOffset, vOffset: LongInt);
  815.     function WELongPointInLongRect ({const} var lp: LongPt;
  816.                                     {const} var lr: LongRect): Boolean;
  817.  
  818. {$ALIGN RESET}
  819. {$POP}
  820.  
  821. implementation
  822. end.